include Makefile.param

OBJS := 
subdir := media network
CONF_HEADER := config.h 

## module media ##
obj-y := 
include media/Makefile
OBJS += $(foreach obj, $(strip $(obj-y)), media/$(obj))

## module network ##
obj-y := 
include network/Makefile
OBJS += $(foreach obj, $(strip $(obj-y)), network/$(obj))

#-------------------------------------------------------
# target build
#
all:test

config: .config
ifneq ($(strip $(CONFIG_HAVE_DOT_CONFIG)),y)
	@echo '	Please Configure using mconf tool.'
	@echo '	Usage: mconf <config.in>'
	@exit 1
else
	@echo '	Have configured,generate $(CONF_HEADER) file'
	@echo '#ifndef __CONFIG_H__' > $(CONF_HEADER)
	@echo '#define __CONFIG_H__' >> $(CONF_HEADER)
	@echo ' ' >> $(CONF_HEADER)
	@sed -e '/is not set/d;s/^#/\/\//g;s/^CONFIG.*$$/#define &/g;s/=y/\t1/g;s/=/\t/g' .config >> $(CONF_HEADER)
	@echo ' ' >> $(CONF_HEADER)
	@echo '#endif' >> $(CONF_HEADER)
	@echo '	Generate $(CONF_HEADER) file ok.'
endif

test: config $(OBJS) 
	@set -e;echo 'OBJS = $(OBJS)'
	$(CC) -o $@ $(OBJS)

$(foreach obj,$(OBJS),$(obj)):%.o:%.c
	@set -e;echo '	CC $@';$(CC) -c $< -o $@

clean:
	@rm -f $(OBJS) test $(CONF_HEADER)

.PHONY:all config test clean 

